import { PageReq, PageRes } from '@/api/types'
import request from '@/utils/request'
import { ScrapModel } from '@/api/model/scrap-model'

// 获取报废列表
export function scrapPageApi(data: PageReq<Partial<any>>) {
  return request<PageRes<any>>({
    url: '/scrap/page',
    method: 'post',
    data
  })
}

// 新增报废
export function addScrapApi(data: Partial<ScrapModel>) {
  return request({
    url: '/scrap/add',
    method: 'post',
    data
  })
}

// 更新报废
export function editScrapApi(data: Partial<ScrapModel & { id: number }>) {
  return request({
    url: '/scrap/edit',
    method: 'post',
    data
  })
}

// 删除报废
export function delScrapApi(data: { id: number }) {
  return request({
    url: '/scrap/del',
    method: 'post',
    data
  })
}

// 获取报废列表
export function getScrapListApi(data: { isInStore: boolean }) {
  return request({
    url: '/scrap/getScrapList',
    method: 'post',
    data
  })
}

// 获取报废详情
export function getScrapDetailApi(data: { id: number }) {
  return request({
    url: '/scrap/getScrapDetail',
    method: 'post',
    data
  })
}
